Mechanical changes in date handling that made it harm to shim a class
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 27 Jan 2013 05:09:20 +0000 (05:09 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 27 Jan 2013 05:09:20 +0000 (05:09 +0000)
"merely" overloading operators from time_t into a real class into place.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4259 f51c46e8-681c-474f-0cfe-069cfd0219fb

12 files changed:
gpsbabel/compegps.cc
gpsbabel/destinator.cc
gpsbabel/exif.cc
gpsbabel/garmin_txt.cc
gpsbabel/igc.cc
gpsbabel/jtr.cc
gpsbabel/magproto.cc
gpsbabel/mapasia.cc
gpsbabel/pathaway.cc
gpsbabel/pcx.cc
gpsbabel/skyforce.cc
gpsbabel/stmwpp.cc

index 19630303871e994f6f0edea98502d343e0957b4d..66a29e5928eed4eb7a173dafb1a9a5a4c5ad9f5e 100644 (file)
@@ -560,7 +560,6 @@ static void
 write_trkpt_cb(const waypoint* wpt)
 {
   char buff[128];
-  struct tm tm;
 
   if ((curr_index != target_index) || (wpt == NULL)) {
     return;
@@ -569,7 +568,9 @@ write_trkpt_cb(const waypoint* wpt)
   buff[0] = '\0';
 
   if (wpt->creation_time != 0) {
-    tm = *gmtime(&wpt->creation_time);
+    const time_t tt = wpt->creation_time;
+    struct tm tm = *gmtime(&tt);
+
     strftime(buff, sizeof(buff), "%d-%b-%y %H:%M:%S", &tm);
     strupper(buff);
   } else {
index 116c0c44efe6ef225593cdfab0664d4a61b535dd..e8f63d22248cb181f026889e8048220610eeaa42 100644 (file)
@@ -436,8 +436,8 @@ destinator_trkpt_disp(const waypoint* wpt)
     struct tm tm;
     double time;
     int date;
-
-    tm = *gmtime(&wpt->creation_time);
+    const time_t ct = wpt->creation_time;
+    tm = *gmtime(&ct);
     tm.tm_mon += 1;
     tm.tm_year -= 100;
     date = ((int)tm.tm_mday * 10000) + ((int)tm.tm_mon * 100) + tm.tm_year;
index ae9640563e8bae5ff81f215801fb08d26d170b3f..848c76d0809d9d0694c4238648b24d645196d34c 100644 (file)
@@ -1488,7 +1488,9 @@ exif_write(void)
       struct tm tm;
       char buf[32];
 
-      tm = *gmtime(&wpt->creation_time);
+      const time_t tt = wpt->creation_time;
+      tm = *gmtime(&tt);
+
       tm.tm_year += 1900;
       tm.tm_mon += 1;
 
index ada15e5eba88048fa1da64ecc1d984a1dd180d39..23093a8858f7fd2b6f9ba0565795049dbac3a8d8 100644 (file)
@@ -1182,8 +1182,11 @@ parse_waypoint(void)
       GMSD_SETSTR(country, str);
       GMSD_SETSTR(cc, gt_get_icao_cc(str, wpt->shortname));
       break;
-    case 16:
-      parse_date_and_time(str, &wpt->creation_time);
+    case 16: {
+      time_t ct;
+      parse_date_and_time(str, &ct);
+      wpt->creation_time = ct;
+      }
       break;
     case 17:
       wpt->url = DUPSTR(str);
@@ -1296,8 +1299,11 @@ parse_track_waypoint(void)
       parse_coordinates(str, datum_index, grid_index,
                         &wpt->latitude, &wpt->longitude, MYNAME);
       break;
-    case 2:
-      parse_date_and_time(str, &wpt->creation_time);
+    case 2: {
+      time_t ct;
+      parse_date_and_time(str, &ct); 
+      wpt->creation_time = ct;
+      }
       break;
     case 3:
       if (parse_distance(str, &x, 1, MYNAME)) {
index 2bc7dde78ad9feca8002dc6c51036e913034131d..f6aee33840fcc7649cab344b1856224d8516af4b 100644 (file)
@@ -690,7 +690,10 @@ static void wr_fix_record(const waypoint* wpt, int pres_alt, int gnss_alt)
 {
   struct tm* tm;
 
-  if (NULL == (tm = gmtime(&wpt->creation_time))) {
+  const time_t tt = wpt->creation_time;
+  tm = gmtime(&tt);
+
+  if (NULL == tm) {
     fatal(MYNAME ": bad track timestamp\n");
   }
 
index 861928a214ae9de9afd2554f2f5d27f7d7560a57..dbeff1bc6b6d05a8db776186f6d9cb4b8169a994 100644 (file)
@@ -273,7 +273,9 @@ jtr_trkpt_disp_cb(const waypoint* wpt)
   struct tm tm;
 
   if (wpt->creation_time > 0) {
-    tm = *gmtime(&wpt->creation_time);
+    const time_t tt = wpt->creation_time;
+    tm = *gmtime(&tt);
+
     tm.tm_year += 1900;
     tm.tm_mon += 1;
     snprintf(sdate, sizeof(sdate), "%02d%02d%02d", tm.tm_mday, tm.tm_mon, tm.tm_year % 100);
index ae3047ed623603d40df5ce18d6b3c822c112f70c..6be7a1edd5555c38f98e6332436e5fb3ce438489 100644 (file)
@@ -1442,7 +1442,8 @@ void mag_track_disp(const waypoint* waypointp)
   ilon = waypointp->longitude;
   tm = NULL;
   if (waypointp->creation_time) {
-    tm = gmtime(&waypointp->creation_time);
+    const time_t ct = waypointp->creation_time;
+    tm = gmtime(&ct);
     if (tm) {
       hms = tm->tm_hour * 10000 + tm->tm_min  * 100 +
             tm->tm_sec;
index 25ab6c6331fb4b226e60d132dd9dc58ba9b025e6..7c306a9fd81857a9fc5323742712ea667e9aedef 100644 (file)
@@ -241,7 +241,8 @@ tr7_disp_waypt_cb(const waypoint* wpt)
   }
 
   if (wpt->creation_time) {
-    tm = *gmtime(&wpt->creation_time);
+    const time_t tt = wpt->creation_time;
+    tm = *gmtime(&tt);
 
     le_write16(&buff[TR7_S_YEAR], tm.tm_year + 1900);
     buff[TR7_S_MONTH] = tm.tm_mon + 1;
index 9a4bc9142f5d92f08440e1c857bfcfdf1c62da6f..2216e6790f8a4179a7b269709c84a9c2fceb9c45 100644 (file)
@@ -689,7 +689,8 @@ static void ppdb_write_wpt(const waypoint *wpt)
 
   if (wpt->creation_time != 0) {
     tmp = str_pool_get(20);
-    tm = *gmtime(&wpt->creation_time);
+    const time_t tt = wpt->creation_time;
+    tm = *gmtime(&tt);
     strftime(tmp, 20, datefmt, &tm);
     buff = ppdb_strcat(buff, tmp, NULL, &len);
   }
index c30ce305ed39358024b61d139e1c196e9f0bca1a..0f5ca968bb000f67a98839d951416910b34ac74d 100644 (file)
@@ -406,7 +406,8 @@ pcx_track_disp(const waypoint *wpt)
   lon = degrees2ddmm(wpt->longitude);
   lat = degrees2ddmm(wpt->latitude);
 
-  tm = gmtime(&wpt->creation_time);
+  const time_t ct = wpt->creation_time;
+  tm = gmtime(&ct);
 
   strftime(tbuf, sizeof(tbuf), "%d-%b-%y %H:%M:%S", tm);       /* currently ...%T does nothing under Windows */
   for (tp = tbuf; *tp; tp++) {
index e6e7ae37df6dd84aad35133e69d6c26c069734fb..8b2550387cba8cb122ee0602f2dd61ad47d8b007 100644 (file)
@@ -176,7 +176,8 @@ skyforce_waypt_disp_cb(const waypoint *wpt)
   if (global_opts.objective == trkdata) {
     struct tm tm;
 
-    tm = *gmtime(&wpt->creation_time);
+    const time_t tt = wpt->creation_time;
+    tm = *gmtime(&tt);
     strftime(buf + 2, sizeof(buf) - 2, "%d%m%y  %H%M%S    ", &tm);
   } else {
     char *name;
index df2dbede67648d8fbc1257eda7af248a5d808b84..d50b9a6cf9433e158b85f0b6da6b8d6dacb471ec 100644 (file)
@@ -239,7 +239,8 @@ stmwpp_waypt_cb(const waypoint *wpt)
     return;
   }
 
-  tm = *gmtime(&wpt->creation_time);
+  const time_t tt = wpt->creation_time;
+  tm = *gmtime(&tt);
   tm.tm_year += 1900;
   tm.tm_mon++;